﻿using System.Data.Entity;

namespace UnitTest.Context
{
    public class UserContext : DbContext
    {
        //static UserContext()
        //{
        //    Database.SetInitializer<UserContext>(null);
        //}

        public UserContext()
            : this("EfConnectString")
        {
            //Configuration.ProxyCreationEnabled = false;
            //Configuration.LazyLoadingEnabled = false;
        }

        public UserContext(string nameOrConnectionString)
            : base(nameOrConnectionString)
        {
        }

        //public DbSet<User> Users { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //modelBuilder.Configurations.Add(new UserConfiguration());
            ////移除一对多的级联删除
            //modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();

            ////注册实体配置信息
            //ICollection<IEntityMapper> entityMappers = DatabaseInitializer<UserContext>.EntityMappers;
            //foreach (IEntityMapper mapper in entityMappers)
            //{
            //    mapper.RegistTo(modelBuilder.Configurations);
            //}
        }
    }
}